package tools

import "regexp"
import "strings"

func Encode(title string) string {
	title = strings.ToLower(title)
	reg1 := regexp.MustCompile("[^a-z0-9]+")
	res1 := reg1.ReplaceAllString(title, "_")
	reg2 := regexp.MustCompile("^_+|_+$")
	res2 := reg2.ReplaceAllString(res1, "")
	reg3 := regexp.MustCompile("_+")
	res3 := reg3.ReplaceAllString(res2, "_")
	return res3
}
